package leetcode.code1409;

import java.util.ArrayList;
import java.util.List;

import leetcode.IDebug;

public class Solution implements IDebug {

	public int[] processQueries(int[] queries, int m) {
		List<Integer> list = new ArrayList<>();
		for (int i = 1; i <= m; i++) {
			list.add(i);
		}
		int len = queries.length;
		int[] ans = new int[len];
		for (int i = 0; i < len; i++) {
			for (int j = 0; j < m; j++) {
				if (list.get(j) == queries[i]) {
					ans[i] = j;
					list.remove(j);
					list.add(0, queries[i]);
					break;
				}		
			}
		}
		return ans;
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
